﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Security;
using System.Web.Configuration;


namespace OnlineBusTicket
{
    public partial class ListAllUserRole : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (IsPostBack == false)
            {
                
                SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("SELECT dbo.aspnet_Users.UserName, dbo.aspnet_Roles.RoleName FROM  dbo.aspnet_Roles INNER JOIN dbo.aspnet_UsersInRoles ON dbo.aspnet_Roles.RoleId = dbo.aspnet_UsersInRoles.RoleId INNER JOIN dbo.aspnet_Users ON dbo.aspnet_UsersInRoles.UserId = dbo.aspnet_Users.UserId", con);
                DataSet ds = new DataSet();
                da.Fill(ds);
                GridView11.DataSource = ds;
                GridView11.DataBind();

                var listRole = Roles.GetAllRoles();
                GridView2.DataSource = listRole;
                GridView2.DataBind();              
            }
        }
        protected void btnChangeRole_Click(object sender, EventArgs e)
        {
            Response.Redirect("ChangeRole.aspx");
        }

        protected void btnChangrRoleName_Click(object sender, EventArgs e)
        {
            Response.Redirect("ChangeRoleName.aspx");
        }

        protected void btnAddNewRole_Click(object sender, EventArgs e)
        {
            Response.Redirect("CreateRole.aspx");
        }
   }
}